# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=go-jsonnet
pkgver=0.20.0
pkgrel=6
pkgdesc="Implementation of Jsonnet in Go"
url="https://jsonnet.org"
arch="all"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/go-jsonnet/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

case "$CARCH" in
	s390x|riscv64) options="!check" ;; # blocked by rapidyaml -> jsonnet-dev
	*) checkdepends="jsonnet-dev" ;;
esac

build() {
	for bin in jsonnet jsonnetfmt jsonnet-deps jsonnet-lint; do
		go build ./cmd/$bin
	done
}

check() {
	# C bindings tests (using Python) depend on the vendored jsonnet C++ source code
	go test ./...
}

package() {
	for bin in jsonnet jsonnetfmt jsonnet-deps jsonnet-lint; do
		install -Dm755 ./$bin -t "$pkgdir"/usr/bin/
	done
}

sha512sums="
0ba06e254a6442764fd016c912968ab373b7fd21044175bbbc465b8fbda42f669bcbbd30d518427279d44f84b9b7678f7152192116c58c4b0bd1642f24136a3c  go-jsonnet-0.20.0.tar.gz
"
